package com.example.musicplayer;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class SongDetailActivity extends AppCompatActivity {

    private TextView titleTextView;
    private TextView artistTextView;
    private TextView albumTextView;
    private TextView durationTextView;
    private TextView pathTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_song_detail);

        // 初始化视图
        initViews();

        // 获取并显示歌曲详情
        displaySongDetails();
    }

    private void initViews() {
        titleTextView = findViewById(R.id.detail_title);
        artistTextView = findViewById(R.id.detail_artist);
        albumTextView = findViewById(R.id.detail_album);
        durationTextView = findViewById(R.id.detail_duration);
        pathTextView = findViewById(R.id.detail_path);
    }

    private void displaySongDetails() {
        // 从Intent获取数据
        String title = getIntent().getStringExtra("title");
        String artist = getIntent().getStringExtra("artist");
        String album = getIntent().getStringExtra("album");
        String duration = getIntent().getStringExtra("duration");
        String path = getIntent().getStringExtra("path");

        // 设置数据到视图
        titleTextView.setText(title);
        artistTextView.setText(artist);
        albumTextView.setText(album);
        durationTextView.setText(duration);
        pathTextView.setText(path);

        // 设置ActionBar标题
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle("歌曲详情");
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    @Override
    public boolean onSupportNavigateUp() {
        finish();
        return true;
    }
}
